package com.ethink.platform.controller.system;

import com.ethink.framework.common.web.BaseController;
import com.ethink.framework.common.web.response.CommonResponse;
import com.ethink.system.api.SystemMenuFacade;
import com.ethink.system.api.info.SystemMenuInfo;
import com.ethink.system.api.request.SystemMenuAddRequest;
import com.ethink.system.api.request.SystemMenuQueryRequest;
import com.ethink.system.api.request.SystemMenuUpdateRequest;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 系统菜单表 Controller
 *
 * @author default
 * @date 2022-09-26
 */
@Tag(name = "SystemMenuController", description = "系统菜单表 Controller")
@RestController
@Slf4j
@RequestMapping("platform-server/v1/system-service")
public class SystemMenuController extends BaseController {

    @Autowired
    private SystemMenuFacade systemMenuFacade;

    @Operation(summary = "查询所有")
    @GetMapping("/systemMenu/list")
    public CommonResponse<List<SystemMenuInfo>> getSystemMenuList(SystemMenuQueryRequest request) {
        return succeedWith(systemMenuFacade.getSystemMenuList(request));
    }

    @Operation(summary = "根据Id查询")
    @GetMapping("/systemMenu/get/{systemMenuId}")
    public CommonResponse<SystemMenuInfo> getSystemMenuById(@PathVariable("systemMenuId") Long systemMenuId) {
        return succeedWith(systemMenuFacade.getSystemMenuById(systemMenuId));
    }

    @Operation(summary = "新增")
    @PostMapping("/systemMenu/add")
    public CommonResponse addSystemMenu(@RequestBody SystemMenuAddRequest request) {
        systemMenuFacade.addSystemMenu(request);
        return succeed();
    }

    @Operation(summary = "修改")
    @PutMapping("/systemMenu/update")
    public CommonResponse updateSystemMenu(@RequestBody SystemMenuUpdateRequest request) {
        systemMenuFacade.updateSystemMenu(request);
        return succeed();
    }

    @Operation(summary = "删除")
    @PutMapping("/systemMenu/get/{systemMenuId}")
    public CommonResponse deleteSystemMenu(@PathVariable("systemMenuId") Long systemMenuId) {
        systemMenuFacade.deleteSystemMenu(systemMenuId);
        return succeed();
    }

}